home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / usenet / st80_pre4 / MacBracketCodes.st < prev    next >
Text File  |  1993-07-24  |  2KB  |  69 lines

  1. "    NAME        MacBracketCodes
  2.     AUTHOR        Dag Svanaes <dags@zevs.ifi.unit.no>
  3.     FUNCTION    char code correction for Mac
  4.     ST-VERSION    2.5
  5.     PREREQUISITES    
  6.     CONFLICTS    
  7.     DISTRIBUTION    world
  8.     VERSION        1
  9.     DATE     9 September 1991
  10. SUMMARY
  11. I am using Eudora on a Mac II.
  12.  
  13. I had to convert it though because of inconsistency in ASCII codes
  14. for '[', ']', '|' and '\'. Please find enclosed the changes to
  15. ExternalReadStream (version 2.5) to fix it if that is to any use.
  16. "!
  17.  
  18.  
  19. !ExternalReadStream methodsFor: 'accessing'!
  20.  
  21. nextAsItWas
  22.     "Answer the next object in the Stream represented by the receiver."
  23.  
  24.     | ch |
  25.     position >= readLimit
  26.         ifTrue: [ch _ self pastEnd.
  27.                 ch == nil ifTrue: [^nil]]
  28.         ifFalse: [ch _ collection at: (position _ position + 1)].
  29.     (binary or: [lineEndConvention == LineEndCR])
  30.         ifTrue: [^ch].
  31.     lineEndConvention == LineEndLF
  32.         ifTrue: [ch == LF
  33.                 ifTrue: [^CR]
  34.                 ifFalse: [^ch]].
  35.     lineEndConvention == LineEndCRLF
  36.     ifTrue: [ch == CR
  37.         ifTrue: [position >= readLimit
  38.             ifTrue: [ch _ self pastEnd.
  39.                 ch == nil ifTrue: [^CR]]
  40.             ifFalse: [ch _ collection at: (position _ position + 1)].
  41.                 ch == LF ifFalse: [position _ position - 1].
  42.                             ^CR]
  43.         ifFalse: [^ch]].
  44.     lineEndConvention == LineEndTransparent
  45.     ifTrue: [^ch]! !
  46.  
  47. !ExternalReadStream methodsFor: 'MacCharCodes'!
  48.  
  49. next
  50.  
  51.     "Added by Dag Svanaes because SMALLTALK/goodies have wrong
  52.     ASCII code for brackets. (As seen from my Mac)"
  53.  
  54.     | ch |
  55.     
  56.     ch _ self nextAsItWas.
  57.     "ch _ $x. self halt."
  58.     
  59.     ((ch asciiValue) = 191) ifTrue: [ ch _ ('|' at: 1)].
  60.     ((ch asciiValue) = 174) ifTrue: [ ch _ ('[' at: 1)].
  61.     ((ch asciiValue) = 129) ifTrue: [ ch _ (']' at: 1)].
  62.     ((ch asciiValue) = 175) ifTrue: [ ch _ ('\' at: 1)].
  63.  
  64.       ^ ch.! !
  65.  
  66.  
  67.  
  68.  
  69.